// import operate from '@feidao/web/atom/nodejs/db/operate';
import count from '@dfeidao/atom-nodejs/db/count';
import query from '@dfeidao/atom-nodejs/db/query';


// import sys_date from '@feidao/web/atom/nodejs/msg/sys-date'; // 获取系统时间
// import { IBaseTable } from '@dfeidao/service/interfaces';
// import { systemid } from './config';
interface Message {
	filter: {
		tenant_name: string;
		productid: string;
	};
	asc: string[];
	desc: string[];
	// systemid: string,
	page_size: number;
	page_no: number;
}

// 用户列表初始化查询
export default async function atom(msg: Message, action_id: string, session_id: string) {
	const systemid = '12';
	const { exec, prepare } = query(action_id, session_id, systemid);
	prepare('pub_tenant', ['_id', 'productid', "tenantid", 'tenant_name', 'link_man', 'phone', 'email', 'tenant_level', 'is_disable', 'create_time'], { tenant_name: { $like: `%${msg.filter.tenant_name || ''}%` }, productid: msg.filter.productid }
		, msg.page_size, msg.page_no, [], []);
	const [data] = await exec();
	const { exec: e3, prepare: p3 } = count(action_id, session_id, systemid);
	p3('pub_tenant', { tenant_name: { $like: `%${msg.filter.tenant_name || ''}%` }, productid: msg.filter.productid });
	const [n1] = await e3();
	return { dataArray1: data, count: n1 };
}
